import { ref } from 'vue'

function useMouseScale() {
  const scale = ref(1)
  const onMousewheel = (event: any) => {
    event.preventDefault()
    const delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail))

    // 在此处理滚轮事件
    if (delta > 0) {
      scale.value += 0.1
    }
    else if (delta < 0) {
      scale.value -= 0.1
    }
    scale.value = Math.min(3, scale.value)
    scale.value = Math.max(0.3, scale.value)
  }

  return {
    scale,
    onMousewheel,
  }
}

export default useMouseScale
